Abstract Fiction generators based on goal-directed planning in a simple state machine can produce reasonably human-like output withoutâŚ
Abstract
Fiction generators based on goal-directed planning in a simple state machine
can produce reasonably human-like output without explicit modeling of multiple
characters by treating the planner as the narrator and protagonist.
Background
Fiction generation using world models is not new. The same kind of planning
used in SHRDLU (Winograd, 1972)
drove early planner-based fiction generators like TALE-SPIN (Meehan,
1976). This
class of fiction generators is a middle ground between âsimulationistâ models,
wherein a large number of variables are modeled carefully and a story is
extracted from the progression between states by dropping most of the
information modelled, and âtextureâ models, wherein large pieces of
preexisting flavor text are pieced together. (An example of the former would
be the history of the world produced by Dwarf
Fortress, and an
example of the latter would be BRUTUS (Bringsjord,
2000).) TALE-SPIN-like
planner-based fiction generators have, historically, like TALE-SPIN, modeled a
set of characters and modeled their interactions. The most interesting stories
generated by these generators remain the âmis-spun talesâ, wherein assumptions
by the generator are flawed in a way that produces absurd violations of common
sense; the remainder of tales are fairly mundane transcripts of interactions
between characters. As demonstrations of a functional model, these transcripts
are serviceable; as stories, they lack interesting forms of structured
conflict.
Author Jim Butcher presents a model of plot construction I call the âscene-sequel modelâ that diverges from the idea of the world as a perfect simulation and focuses on the kinds of stories readers find interesting. While Butcherâs interest is in human-written stories, his ideas lend themselves to generative fiction more so than other seemingly more mechanical models of plot construction like Plotto and the [BS2](http://www.savethecat.com/tools/the-blake-snyder-beat-sheet-the- bs2). Quickly: within the scene-sequel model, a story has a single protagonist and consists of scenes (wherein the protagonist attempts to achieve his or her goal) and sequels (wherein the protagonist reacts to the content of the scene emotionally and performs his or her planning); scenes have scene-specific goals that are either achieved or not achieved and each scene may introduce complications that change the protagonistâs state.
Current work
For NaNoGenMo 2015, I present a
fiction generator based on a
simplified scene-sequel model for caper novels. In this model, there is only
one character modeled: the protagonist, who is also the narrator. The content
of the story is generated by the planner with the help of flavor text.
The story is generated by the planner from a âworld modelâ, which is a state machine with associated flavor text. The world model consists of a list of state objects; each state object has a list of other states it can transition to (along with a probability for this transition to occur and optional flavor text for describing attempted, successful, and failed transitions). It furthermore contains a set of potential complications, which themselves are state names paired with probabilities.
The planner is provided with a world model, a weight for state transition success rate, a weight for complication accretion rate, a starting state, and a goal state. The planner keeps a âgoal poolâ consisting of a set of state names and weights, and this goal pool is initially set to the goal state. Typically, the goal state is the overarching goal of the protagonist. As complications are accrued, they are added to the goal pool.
At each step, we perform a sequel followed by a scene.
The sequel consists of information produced by the planner, which (starting from the current state) performs a walk of the state space, depth-first, searching for the goal state. Because the world object contains cycles, the tree-walking portion of the planner is provided with a recursion depth limit. The planner, multiplying and adding probabilities, determines the immediate next state with the greatest composite likelihood of reaching each state in the goal pool â in other words, the likelihood of reaching each goal is determined, adjusted by its goal weight, and then a composite is produced for ranking purposes. During this tree-walking and goal-weighing process, at an adjustable rate, information about the planning process and the decisions being made is emitted in the style of first-person narration of planning in a caper novel:
So, I thought, what if I tried to steal them jewels by trying to get a museum uniform⌠So, I thought, what if I tried to steal them jewels by trying to pass as a museum employee⌠So, I thought, what if I tried to steal them jewels by trying to go to the hospital⌠Iâll try to remember that.
So, I figured, if I tried to steal them jewels by trying to pass as a museum employee Iâd have maybe a 35% chance of succeding. Iâll try to remember that.
If Iâm trying to get a museum uniform, what if In order to steal them jewels, I tried to pass as a museum employee. That has about a 1 in 10 chance of working. So, I figured, if I tried to steal them jewels by trying to get a museum uniform Iâd have maybe a 10% chance of succeding. Iâll try to remember that.
So, since Iâm trying to go about it the obvious way I decided to steal them jewels by trying to get a museum uniform. So, I have to get a museum uniform. I also have to steal them jewels. Right now, Iâm trying to go about it the obvious way.
Once the planner has produced a candidate state, it uses the likelihood of success for the specific state transition and the global state transition weight to determine whether or not it succeeds, producing the appropriate flavor text (or a default if undefined), and then produces the set of complications to add. If the state transition is successful and the new state is the end goal state, the program stops here; if the state transition is successful and the new state is in the goal pool, that entry is removed from the goal pool.
Here is an example of the full output, using a world model about jewel theft:
This is the story of that time I decided to try and steal them jewels.
So, I thought, what if I tried to steal them jewels by trying to get a museum uniform⌠So, I thought, what if I tried to steal them jewels by trying to pass as a museum employee⌠So, I thought, what if I tried to steal them jewels by trying to go to the hospital⌠Iâll try to remember that.
So, I figured, if I tried to steal them jewels by trying to pass as a museum employee Iâd have maybe a 35% chance of succeding. Iâll try to remember that.
If Iâm trying to get a museum uniform, what if In order to steal them jewels, I tried to pass as a museum employee. That has about a 1 in 10 chance of working. So, I figured, if I tried to steal them jewels by trying to get a museum uniform Iâd have maybe a 10% chance of succeding. Iâll try to remember that.
So, since Iâm trying to go about it the obvious way I decided to steal them jewels by trying to get a museum uniform. So, I have to get a museum uniform. I also have to steal them jewels. Right now, Iâm trying to go about it the obvious way.
I failed to get a museum uniform while trying to go about it the obvious way. Bummer. Now I have to get a smaller gun. I still need to steal them jewels.
So, I thought, what if I tried to get a smaller gun by trying to get a museum uniform⌠So, I thought, what if I tried to get a smaller gun by trying to pass as a museum employee⌠So, I thought, what if I tried to get a smaller gun by trying to go to the hospital⌠So, I thought, what if I tried to get a smaller gun by trying to steal them jewels⌠Iâll try to remember that.
So, I thought, what if I tried to steal them jewels by trying to get a museum uniform⌠I already figured that if I tried to steal them jewels by trying to get a museum uniform Iâd only have about a 1 in 10 chance of succeeding.
So, since Iâm trying to go about it the obvious way I decided to steal them jewels by trying to get a museum uniform. So, I have to get a museum uniform. I also have to get a smaller gun. I also have to steal them jewels. Right now, Iâm trying to go about it the obvious way.
I failed to get a museum uniform while trying to go about it the obvious way. Bummer. I still need to get a smaller gun. I also still need to steal them jewels.
So, I thought, what if I tried to get a smaller gun by trying to get a museum uniform⌠So, I thought, what if I tried to steal them jewels by trying to get a museum uniform⌠I already figured that if I tried to steal them jewels by trying to get a museum uniform Iâd only have about a 1 in 10 chance of succeeding.
So, since Iâm trying to go about it the obvious way I decided to steal them jewels by trying to get a museum uniform. So, I have to get a museum uniform. I also have to get a smaller gun. I also have to steal them jewels. Right now, Iâm trying to go about it the obvious way.
I failed to get a museum uniform while trying to go about it the obvious way. Bummer. I still need to get a smaller gun. I also still need to steal them jewels.
So, I thought, what if I tried to get a smaller gun by trying to get a museum uniform⌠So, I thought, what if I tried to steal them jewels by trying to get a museum uniform⌠I already figured that if I tried to steal them jewels by trying to get a museum uniform Iâd only have about a 1 in 10 chance of succeeding.
So, since Iâm trying to go about it the obvious way I decided to steal them jewels by trying to get a museum uniform. So, I have to get a museum uniform. I also have to get a smaller gun. I also have to steal them jewels. Right now, Iâm trying to go about it the obvious way.
I totally succeeded in my attempt to get a museum uniform by trying to go about it the obvious way. Yay! Now I have to get a smaller gun, again. I still need to steal them jewels.
So, I thought, what if I tried to get a smaller gun by trying to pass as a museum employee⌠So, I thought, what if I tried to steal them jewels by trying to pass as a museum employee⌠I already figured that if I tried to steal them jewels by trying to pass as a museum employee Iâd only have about a 3 in 10 chance of succeeding.
So, since Iâm trying to get a museum uniform I decided to steal them jewels by trying to pass as a museum employee. So, I have to pass as a museum employee. I also have to get a smaller gun. I also have to steal them jewels. Right now, Iâm trying to get a museum uniform.
I failed to pass as a museum employee while trying to get a museum uniform. Bummer. I still need to get a smaller gun. I also still need to steal them jewels.
So, I thought, what if I tried to get a smaller gun by trying to pass as a museum employee⌠So, I thought, what if I tried to steal them jewels by trying to pass as a museum employee⌠I already figured that if I tried to steal them jewels by trying to pass as a museum employee Iâd only have about a 3 in 10 chance of succeeding.
So, since Iâm trying to get a museum uniform I decided to steal them jewels by trying to pass as a museum employee. So, I have to pass as a museum employee. I also have to get a smaller gun. I also have to steal them jewels. Right now, Iâm trying to get a museum uniform.
I failed to pass as a museum employee while trying to get a museum uniform. Bummer. I still need to get a smaller gun. I also still need to steal them jewels.
So, I thought, what if I tried to get a smaller gun by trying to get a museum uniform⌠So, I thought, what if I tried to steal them jewels by trying to get a museum uniform⌠I already figured that if I tried to steal them jewels by trying to get a museum uniform Iâd only have about a 1 in 10 chance of succeeding.
So, since Iâm trying to go about it the obvious way I decided to steal them jewels by trying to get a museum uniform. So, I have to get a museum uniform. I also have to get a smaller gun. I also have to steal them jewels. Right now, Iâm trying to go about it the obvious way.
I totally succeeded in my attempt to get a museum uniform by trying to go about it the obvious way. Yay! Now I have to get a smaller gun, again. I still need to steal them jewels.
So, I thought, what if I tried to get a smaller gun by trying to pass as a museum employee⌠So, I thought, what if I tried to steal them jewels by trying to pass as a museum employee⌠I already figured that if I tried to steal them jewels by trying to pass as a museum employee Iâd only have about a 3 in 10 chance of succeeding.
So, since Iâm trying to get a museum uniform I decided to steal them jewels by trying to pass as a museum employee. So, I have to pass as a museum employee. I also have to get a smaller gun. I also have to steal them jewels. Right now, Iâm trying to get a museum uniform.
I totally succeeded in my attempt to pass as a museum employee by trying to get a museum uniform. Yay! Now I have to escape the museum. I still need to get a smaller gun. I also still need to steal them jewels.
So, I thought, what if I tried to get a smaller gun by trying to go to the hospital⌠So, I thought, what if I tried to escape the museum by trying to go to the hospital⌠So, I thought, what if I tried to steal them jewels by trying to go to the hospital⌠So, I thought, what if I tried to get a smaller gun by trying to steal them jewels⌠So, I thought, what if I tried to escape the museum by trying to steal them jewels⌠So, I thought, what if I tried to steal them jewels by trying to steal them jewels⌠It turns out thereâs no way to steal them jewels by trying to go to the hospital after you already tried to pass as a museum employee.
So, since Iâm trying to pass as a museum employee I decided to steal them jewels by trying to steal them jewels. So, I have to steal them jewels. I also have to get a smaller gun. I also have to escape the museum. Right now, Iâm trying to pass as a museum employee.
I totally succeeded in my attempt to steal them jewels by trying to pass as a museum employee. Yay! Now I no longer need to steal them jewels. Now I have to heal my arm wound. Now I have to heal my chest wound, too. I still need to get a smaller gun. I also still need to escape the museum.
THE END
Here is the world model that produced that story:
world={}
world[âgo about it the obvious wayâ]={âget a museum uniformâ:{âprobabilityâ:0.5, âcomplicationsâ:{âget a smaller gunâ: { âprobabilityâ:0.9 }}}, âgo to the ninja supply storeâ:{âprobabilityâ:1}, âgo to the gun storeâ:{âprobabilityâ:1}}
world[âgo to gun storeâ]={âget a smaller gunâ:{âprobabilityâ:0.7, âcomplicationsâ:{âfind my stolen walletâ:{ âprobabilityâ:0.2}, âsuccess_descrâ:[âThe gun store carried an antique gun intended for defending women on bicycles against dogs in the late nineteenth century. â, âThe gun store carried a half-scale airsoft dart gun version of a Walther PPK, and poison darts. â]}, âdescrâ:[âThe gun store was a tiny brick building by the side of the highway, in the bad part of town. â], âsuccess_descrâ:[âThe owner glared at me, and then at my ID, and then back at me. Then he grunted, accepted my cash, and handed me the new gun. â], âfailure_descrâ:[âAfter banging on the locked door for ten minutes, I noticed a tiny sign at the lower left hand corner of the window embedded in the door. It had hours. It turns out, this store is closed on Tuesdays. â]}, âgoal_reqsâ:{âorâ:[âget a smaller gunâ]}}
world[âget a smaller gunâ]={âgo to gun storeâ:{âprobabilityâ:1}, âgo about it the obvious wayâ:{âprobabilityâ:1}, âpass as a museum employeeâ:{âprobabilityâ:0.3}}
world[âget a museum uniformâ]={âpass as a museum employeeâ:{âprobabilityâ:0.3, âcomplicationsâ:{âheal my leg woundâ:{ âprobabilityâ:0.2}, âescape the museumâ:{ âprobabilityâ: 0.7} } }, âdescrâ:[âThe costume shop was tucked into a strip mall down town, between a laundromat and a chinese take-out place. It smelled like soap. â], âsuccess_descrâ:[âThere was a perfect museum employee uniform sitting on the rack to the left of the entrance. â], âfailure_descrâ:[âAfter looking through the racks several times, I finally decided to ask the cashier â a wrinkled but plump old woman with a puff of curly white hair â if she carried museum employee uniforms. She shook her head, and I left, dejected. â]}
world[âpass as a museum employeeâ]={âsteal them jewelsâ:{âprobabilityâ:0.7, âcomplicationsâ:{âheal my leg woundâ:{ âprobabilityâ:0.3}, âheal my arm woundâ:{ âprobabilityâ:0.3}, âheal my chest woundâ:{ âprobabilityâ:0.3}}}, âgo to the hospitalâ:{âprobabilityâ:0.9}, âreqsâ:{âorâ:[âget a museum uniformâ]}}
world[âgo to the ninja supply storeâ]={âget a smaller gunâ:{âprobabilityâ:0.4, âsuccess_descrâ:[âIn the glass display case, there was a poison dart gun that looked like a fountain pen. I bought six! â], âfailure_descrâ:[âThe cashier claimed that they had a moral aversion to projectile weapons, and thus did not carry them. â]}, âpurchase a black leather catsuitâ:{âprobabilityâ:0.7, âsuccess_descrâ:[âA beautiful black leather catsuit greeted me from the rack to the left of the doorway. â], âfailure_descrâ:[âAll the black leather catsuits they had in stock were sized for literal cats. â, âAll the black leather cat suits they had in stock were way too big for me. â, âAll their black leather catsuits were covered in shiny chrome studs and buckles, and wouldnât help me disappear into the night at all. â]}, âpurchase a grappling hookâ:{âprobabilityâ:0.7, âsuccess_descrâ:[âThere was a grappling hook with two hundred feet of rope sitting right behind the counter, on display. â, âI spent twenty minutes looking through the discount bin, before finding an absolutely perfect grappling hook for thirty cents. When I went up to pay for it, the cashier waved me off â no charge. â],âfailure_descrâ:[â\âAre there any grappling hooks in stock?\â The cashier, impassive behind his mask, shook his head slowly in response to my question. Then, after a moment of staring at me, he threw a smoke bomb at his feet. I found myself outside the shop, which was now locked. â]}, âdescrâ:[âThe ninja supply shop was in the middle of the second floor of the mall, between a Hot Topic and a Zappoâs. It was dimly lit, and the scuffed floors had a fake tatami-pattern print. There was a wad of gum stuck to the doorway. â], âfailure_descrâ:[âThe shutter was shut, and a great big lock hung from the side of it. â, âThe door was shut and locked, and a sign said \âBack at 2:00\â. It was four. I waited until six. â],âsuccess_descrâ:[âAs I entered, a machine emitted a little beep to indicate that customers were about. The cashier appeared out of a plume of smoke behind the counter. â]}
world[âpurchase a black leather catsuitâ]={âsneak into the museum at nightâ:{âprobabilityâ:0.8}, âgo to the ninja supply storeâ:{âprobabilityâ:1}}
world[âpurchase a grappling hookâ]={âsneak into the museum at nightâ:{âprobabilityâ:0.9}, âgo to the ninja supply storeâ:{âprobabilityâ:1}}
world[âsneak into the museum at nightâ]={âsteal them jewelsâ:{âprobabilityâ:0.8, âcomplicationsâ:{âheal my leg woundâ:{âprobabilityâ:0.3},âheal my arm woundâ:{ âprobabilityâ:0.3}, âheal my chest woundâ:{ âprobabilityâ:0.3}}}, âgo to the hospitalâ:{âprobabilityâ:0.9}, âreqsâ:{âorâ:[âpurchase a black leather catsuitâ, âpurchase a grappling hookâ]}}
world[âgo to the hospitalâ]={âheal my leg woundâ:{âprobabilityâ:0.9}, âheal my arm woundâ:{âprobabilityâ:0.9}, âheal my chest woundâ:{âprobabilityâ:0.7}, âescape the museumâ:{âprobabilityâ:0.7},âgoal_reqsâ:{âorâ:[âheal my leg woundâ, âheal my arm woundâ, âheal my chest woundâ]}}
world[âheal my leg woundâ]={âgo to the hospitalâ:{âprobabilityâ:1}, âget a museum uniformâ:{âprobabilityâ:1}, âget a smaller gunâ:{âprobabilityâ:1}, âgo to the ninja supply storeâ:{âprobabilityâ:1}}
world[âheal my arm woundâ]={âgo to the hospitalâ:{âprobabilityâ:1}, âget a museum uniformâ:{âprobabilityâ:1}, âget a smaller gunâ:{âprobabilityâ:1}, âgo to the ninja supply storeâ:{âprobabilityâ:1}}
world[âheal my chest woundâ]={âgo to the hospitalâ:{âprobabilityâ:1}, âget a museum uniformâ:{âprobabilityâ:1}, âget a smaller gunâ:{âprobabilityâ:1}, âgo to the ninja supply storeâ:{âprobabilityâ:1}}
world[âsteal them jewelsâ]={âsteal them jewelsâ:{âprobabilityâ:1, âcomplicationsâ:{}}}
endGoal=âsteal them jewelsâ
By John Ohno on December 17, 2015.
[Canonical link](https://medium.com/@enkiv2/scene-sequel-post-mortem-of-a- fiction-generator-583ad51f3c1b)
Exported from Medium on September 18, 2020.
Rendering context...